﻿using System.Runtime.InteropServices;
using System.Text.Json;
using BLL.DTO.DataDto;
using BLL.Manager;
using Helper;
using HZY.Framework.DependencyInjection;
using Model;
using Model.EntityInfo;

namespace WinFormsSprayProcessSCADASystem.Pages
{
    [ComVisible(true)]
    public class PageReportManage : IScopedSelfDependency
    {
        private readonly DataLogManager _dataogManager;
        private JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions()
        {
            PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
            WriteIndented = true
        };
        public PageReportManage(DataLogManager logManager)
        {
            _dataogManager = logManager;
        }

        //获取运行数据日志列表
        [ComVisible(true)]
        public async Task<string> GetAllList(string queryStr)
        {
            DataLogListDto data = JsonSerializer.Deserialize<DataLogListDto>(queryStr);
            BaseResult<ResPageData<DataLogInfoModel>> res = await _dataogManager.GetDataLogListAsync(data);
            string jsonResult = JsonSerializer.Serialize(res, _jsonSerializerOptions);
            return jsonResult;
        }
    }
}
